package com.huwei.lngu.kk.elm.gu;

public class zuo {

    public static void main(String[] args) {
        int a= 500;
        int[] a1=new int[500];
        for (int i = 0; i < 500; i++) {
            a1[i] = i + 1;
        }
        int index = 0;
        int count = 0;
        while (a>1){
            if (++count == 3) {
                count=0;
                if (a - 1 - index >= 0) System.arraycopy(a1, index + 1, a1, index, a - 1 - index);
                a--;
            } else {
                index = (index + 1) % a;
            }
        }
        System.out.println("剩下的人是"+a1[0]);
    }

}
